package com.hyc.myvideo.data.adapter.my.recharge;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.hyc.myvideo.R;
import com.hyc.myvideo.data.adapter.base.BaseListAdapter;
import com.hyc.myvideo.data.api.model.Recharge;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 会员充值
 * @author gyb
 * @version 1.0
 * @created 2017/07/18
 */
public class BalanceAdapter extends BaseListAdapter<Recharge> implements View.OnClickListener{

    private Callback mCallback = null;

    public BalanceAdapter(Context context, List<Recharge> objects, Callback callback) {
        super(context, objects);
        this.mCallback = callback;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.activity_adapter_balance_item, parent, false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        Recharge recharge = mDataList.get(position);
        //String dew = String.format(mContext.getString(R.string.huc_my_dew_no), recharge.get);
        holder.textViewDew.setText(recharge.getRecharge_name());
        String money = String.format(mContext.getString(R.string.huc_my_vip_sun), new java.text.DecimalFormat("0.00").format(recharge.getRecharge_rmb()));
        holder.textViewSun.setText(money);
        holder.buttonRecharge.setOnClickListener(this);
        holder.buttonRecharge.setTag(recharge);
        return convertView;
    }

    @Override
    public void onClick(View v) {
        mCallback.click(v);
    }

    //充值回调借口
    public interface Callback{
        public void click(View v);
    }

    public static class ViewHolder {
        public ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
        //露珠
        @BindView(R.id.item_tid)
        TextView textViewDew;
        //金额
        @BindView(R.id.item_t_sum_id)
        TextView textViewSun;
        //充值
        @BindView(R.id.item_b_buy_id)
        Button buttonRecharge;
    }

}
